package com.leigang.rocketmq.controller;

/**
 * @author leig-a
 * @version 1.0
 * @desc
 * @date 2022/6/15 16:27
 */

import com.leigang.rocketmq.config.RocketConsumer;
import com.leigang.rocketmq.config.RocketProducer;
import com.leigang.rocketmq.service.IRockerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RocketController {
    /**
     * topic
     */
    @Value("${message.first.topic}")
    private String topicFirst;

    /**
     * tag
     */
    @Value("${message.first.tag}")
    private String tagFirst;


    /**
     * topic
     */
    @Value("${message.second.topic}")
    private String topicSecond;

    /**
     * tag
     */
    @Value("${message.second.tag}")
    private String tagSecond;

    @Autowired
    private IRockerService rockerService;


    @RequestMapping("/myFirstProducer")
    public String pushMsg(String msg){
        return rockerService.sendMsg(topicFirst,tagFirst,msg);
    }


    @RequestMapping("/mySecondProducer")
    public String pushSecondMsg(String msg){
        return rockerService.sendMsg(topicSecond,tagSecond,msg);
    }


    @RequestMapping("/mySecondConsumer")
    public String pullSecondMsg(){
        rockerService.receiveMsg(topicSecond,tagSecond);
        return "消息接收完成";
    }
}
